package com.ticket.sass.admin.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ticket.sass.admin.annotation.Loggable;
import com.ticket.sass.admin.annotation.Module;
import com.ticket.sass.admin.business.MemberCardLevelBusiness;
import com.ticket.sass.admin.dto.input.member.MemberCardLevelAddInput;
import com.ticket.sass.admin.dto.input.member.MemberCardLevelListInput;
import com.ticket.sass.admin.dto.input.member.MemberCardLevelUpdInput;
import com.ticket.sass.admin.dto.output.member.MemberCardLevelListOutput;
import com.ticket.sass.admin.model.PageModel;
import com.ticket.sass.admin.model.ResultModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 会员卡级别 前端控制器
 * </p>
 *
 * @author ywb
 * @since 2024-03-06
 */
@RestController
@AllArgsConstructor
@ApiSupport(order = 13)
@Api(tags = {"会员卡等级-模块"})
@RequestMapping("/member-card-levels")
public class MemberCardLevelController {
    final MemberCardLevelBusiness memberCardLevelBusiness;
    
    @ApiOperation("列表")
    @GetMapping
    public ResultModel<PageModel<MemberCardLevelListOutput>> list(
        @Valid MemberCardLevelListInput input
    ) {
        return ResultModel.success(
            memberCardLevelBusiness.levelList(input)
        );
    }
    
    @PostMapping
    @ApiOperation("新增")
    @Loggable(module = Module.MEMBER, desc = "新增会员等级")
    public ResultModel<String> add(
        @RequestBody @Valid MemberCardLevelAddInput input
    ) {
        memberCardLevelBusiness.add(input);
        return ResultModel.success();
    }
    
    @PutMapping
    @ApiOperation("修改")
    @Loggable(module = Module.MEMBER, desc = "新增会员等级")
    public ResultModel<String> upd(
        @RequestBody @Valid MemberCardLevelUpdInput input
    ) {
        memberCardLevelBusiness.upd(input);
        return ResultModel.success();
    }
}
